<%@ page language="Java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>


<c:forEach items="${tours}" var="tour">
<fieldset id="field${tour.id}">
<legend>Oferta</legend>
	<div id="div${tour.id}">
		<div>
		<b>Nazwa hotelu:</b> ${tour.hotelDto.name}
		</div>
		<div>
		<b>Miasto:</b> ${tour.hotelDto.cityName}
		</div>
		<div>
		<b>Kraj:</b> ${tour.hotelDto.countryName}
		</div> 
		<div>
		<b>Cena za osobę:</b> ${tour.basePrice}
		</div> 
		<span class="detailsLink" onclick="showDetails(${tour.id})"> Szczegóły </span>
		<span class="detailsLink" onclick="showImages(${tour.id})"> Zdjęcia </span>
	<div id="description${tour.id}"></div>
	<div id="images${tour.id}"></div>
	<br>
	<a href="<c:url value="/user/reservationTourPage.html?tourId=${tour.id}"/>">Zarezerwuj</a>
	</div>
</fieldset>
<br>
</c:forEach>

<script type="text/javascript">
 

function test(param) {
	jq(function(){ 
		var divId = '\"description' + param + '\"';
		
		jq("#description" + param).replaceWith('<div id=' + divId + '> cos tam </div>');
		//jq("#description" + param).html('<div id=' + divId + '> cos tam </div>');
		//jq("#description").html('<div id=' + divId + '> cos tam </div>');
		divId+='teeeeeeeeeeeeeeeeest';
		alert(divId);
		alert(param);	
	});
}

	function showImages(tourId) {
		jq(function() {
			jq.post("/TourWebSpring/tourImages.html",
				{tourId: tourId},
			 function(data) {
				var stringData = new String(data);
				var pathsArray = stringData.split(",");
				var result='';
				var i=0;
				for(i=0; i<pathsArray.length; i++){
					result = result + '<img src=\"img\\' + pathsArray[i] + '\" /> ';
				}
				var divId = '\"images' + tourId + '\"'; 
				jq("#images" + tourId).replaceWith(result);
			});
		});
	}

	function showDetails(tourId) {
		jq(function() {
			jq.post("/TourWebSpring/tourDetail.html",
				{tourId: tourId},
			 function(data) {
				var divId = '\"description' + tourId + '\"'; 
				//jq("#description" + tourId).replaceWith('<div id=' + divId + '>' + data + '</div>');
				jq("#description" + tourId).html('<b>Opis: </b>  '+ data);
			});
		});
	}
</script>